package com.ct.lotterysystem2.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ct.lotterysystem2.dao.dataobject.Encrypt;
import com.ct.lotterysystem2.dao.dataobject.UserDO;
import jakarta.validation.constraints.NotBlank;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<UserDO> {

    @Select("select count(*) from user where phone_number = #{phoneNumber}")
    int countByPhoneNumber(@Param("phoneNumber") String phoneNumber);

    @Select("select count(*) from user where email = #{email}")
    int countByMail(@Param("email") String email);

    @Select("select * from user where email = #{email}")
    UserDO selectByMail(@Param("email") String email);

    @Select("select * from user where phone_number = #{phoneNumber}")
    UserDO selectByPhoneNumber(@Param("phoneNumber") Encrypt phoneNumber);

    @Select("select * from user where identity = #{identity}")
    List<UserDO> selectByIdentity(@Param("identity") String identity);
}
